Page({
  data: {
    schema:[
    ],
    formData:{
    },
    title: '',
    result: '',
    remark: '',
    apiName: '',
    phoneNumber:'',
    content:''
  },
  // 获取输入的手机号
  bindPhoneInput: function(e) {
    this.setData({
      phoneNumber: e.detail.value
    })
  },
  bindContent:function(e){
    this.setData({
      content: e.detail.value
    })
  },
  sendSms(e) {
    let that = this
    // 简单的手机号验证
    if (!/^1[3-9]\d{9}$/.test(that.data.phoneNumber)) {
      wx.showToast({
        title: '请输入正确的手机号',
        icon: 'none'
      });
      return;
    }
    if(!that.data.content){
      wx.showToast({
        title: '请输入短信面板内容',
        icon: 'none'
      });
      return;
    }
    wx.sendSms({
      phoneNumber:that.data.phoneNumber,
      content:that.data.content,
      success: (res) => {
        that.setData({
          result: res,
          apiName: e.currentTarget.dataset.apiname 
        })
      },
      fail(err) {
        that.setData({
          result: err,
          apiName: e.currentTarget.dataset.apiname 
        })
      }
    })
  },
  onLoad(options) {
    wx.setNavigationBarTitle({
      title: options.title,
    })
    
    this.setData({
      title: options.title,
      zh:options.zh,
      remark: options.remark,
      webUrl: options.webUrl
    })
  }
})
